﻿using System;
using Phoenix.ComponentModel;
using Xunit;

namespace Phoenix.Tests.ComponentModel
{
    public class NotifyPropertyChangedTests
    {
        [Fact]
        public void onpropertychanged_expression_raises_propertychanged_event()
        {
            // arrange
            var testClass = new TestClass();
            var propertyName = default(string);
            testClass.PropertyChanged += (sender, args) => propertyName = args.PropertyName;

            // act
            testClass.TestProperty = "Testing";

            // assert
            Assert.Equal("TestProperty", propertyName);
        }

        public class TestClass : NotifyPropertyChanged
        {
            string testProperty;

            public string TestProperty
            {
                get { return testProperty; }
                set
                {
                    testProperty = value;
                    OnPropertyChanged(() => TestProperty);
                }
            }
        }
    }
}